const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");

module.exports = {
  webpack: {
    configure: (webpackConfig) => {
      webpackConfig.resolve.fallback = {
        fs: false,
        path: require.resolve("path-browserify"),
        os: require.resolve("os-browserify/browser"),
        url: require.resolve("url"),
      };

      webpackConfig.plugins.push(
        new CopyWebpackPlugin({
          patterns: [
            {
              from: "node_modules/cesium/Build/Cesium",
              to: "public/Cesium",
            },
          ],
        })
      );

      webpackConfig.resolve.alias = {
        ...webpackConfig.resolve.alias,
        cesium: path.resolve(__dirname, "node_modules/cesium/Source"),
      };

      return webpackConfig;
    },
  },
};